/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package BL;

import java.io.Serializable;
import java.util.Collection;
import javax.persistence.Basic;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.JoinTable;
import javax.persistence.ManyToMany;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.persistence.UniqueConstraint;

/**
 *
 * @author sundas
 */
@Entity
@Table(name = "product", catalog = "newPurchase", schema = "", uniqueConstraints = {@UniqueConstraint(columnNames = {"productNumber"})})
@NamedQueries({@NamedQuery(name = "Product.findAll", query = "SELECT p FROM Product p"), @NamedQuery(name = "Product.findByProductNumber", query = "SELECT p FROM Product p WHERE p.productNumber = :productNumber"), @NamedQuery(name = "Product.findByItemName", query = "SELECT p FROM Product p WHERE p.itemName = :itemName"), @NamedQuery(name = "Product.findByItemBrand", query = "SELECT p FROM Product p WHERE p.itemBrand = :itemBrand"), @NamedQuery(name = "Product.findByBarcode", query = "SELECT p FROM Product p WHERE p.barcode = :barcode"), @NamedQuery(name = "Product.findByUnitPurchasePrice", query = "SELECT p FROM Product p WHERE p.unitPurchasePrice = :unitPurchasePrice"), @NamedQuery(name = "Product.findByUnitSalePrice", query = "SELECT p FROM Product p WHERE p.unitSalePrice = :unitSalePrice"), @NamedQuery(name = "Product.findByReorderQty", query = "SELECT p FROM Product p WHERE p.reorderQty = :reorderQty"), @NamedQuery(name = "Product.findByUnitSize", query = "SELECT p FROM Product p WHERE p.unitSize = :unitSize"), @NamedQuery(name = "Product.findByMinQty", query = "SELECT p FROM Product p WHERE p.minQty = :minQty"), @NamedQuery(name = "Product.findByMaxQty", query = "SELECT p FROM Product p WHERE p.maxQty = :maxQty"), @NamedQuery(name = "Product.findByProdType", query = "SELECT p FROM Product p WHERE p.prodType = :prodType"), @NamedQuery(name = "Product.findByDescription", query = "SELECT p FROM Product p WHERE p.description = :description")})
public class Product implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @Basic(optional = false)
    @Column(name = "productNumber", nullable = false)
    private Integer productNumber;
    @Basic(optional = false)
    @Column(name = "itemName", nullable = false, length = 50)
    private String itemName;
    @Basic(optional = false)
    @Column(name = "itemBrand", nullable = false, length = 50)
    private String itemBrand;
    @Basic(optional = false)
    @Column(name = "barcode", nullable = false, length = 50)
    private String barcode;
    @Basic(optional = false)
    @Column(name = "unitPurchasePrice", nullable = false)
    private float unitPurchasePrice;
    @Basic(optional = false)
    @Column(name = "unitSalePrice", nullable = false)
    private float unitSalePrice;
    @Column(name = "reorderQty")
    private Integer reorderQty;
    @Column(name = "unitSize", length = 10)
    private String unitSize;
    @Column(name = "minQty")
    private Integer minQty;
    @Column(name = "maxQty")
    private Integer maxQty;
    @Column(name = "prodType", length = 10)
    private String prodType;
    @Column(name = "description", length = 150)
    private String description;
    @JoinTable(name = "supplier_product", joinColumns = {@JoinColumn(name = "productNumber", referencedColumnName = "productNumber", nullable = false)}, inverseJoinColumns = {@JoinColumn(name = "supplierId", referencedColumnName = "supplierId", nullable = false)})
    @ManyToMany
    private Collection<Supplier> supplierCollection;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "product")
    private Collection<Stockproduct> stockproductCollection;
    @JoinColumn(name = "groupId", referencedColumnName = "groupId")
    @ManyToOne
    private Prodgroup groupId;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "product")
    private Collection<Price> priceCollection;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "product")
    private Collection<Orderlineitem> orderlineitemCollection;

    public Product() {
    }

    public Product(Integer productNumber) {
        this.productNumber = productNumber;
    }

    public Product(Integer productNumber, String itemName, String itemBrand, String barcode, float unitPurchasePrice, float unitSalePrice) {
        this.productNumber = productNumber;
        this.itemName = itemName;
        this.itemBrand = itemBrand;
        this.barcode = barcode;
        this.unitPurchasePrice = unitPurchasePrice;
        this.unitSalePrice = unitSalePrice;
    }

    public Integer getProductNumber() {
        return productNumber;
    }

    public void setProductNumber(Integer productNumber) {
        this.productNumber = productNumber;
    }

    public String getItemName() {
        return itemName;
    }

    public void setItemName(String itemName) {
        this.itemName = itemName;
    }

    public String getItemBrand() {
        return itemBrand;
    }

    public void setItemBrand(String itemBrand) {
        this.itemBrand = itemBrand;
    }

    public String getBarcode() {
        return barcode;
    }

    public void setBarcode(String barcode) {
        this.barcode = barcode;
    }

    public float getUnitPurchasePrice() {
        return unitPurchasePrice;
    }

    public void setUnitPurchasePrice(float unitPurchasePrice) {
        this.unitPurchasePrice = unitPurchasePrice;
    }

    public float getUnitSalePrice() {
        return unitSalePrice;
    }

    public void setUnitSalePrice(float unitSalePrice) {
        this.unitSalePrice = unitSalePrice;
    }

    public Integer getReorderQty() {
        return reorderQty;
    }

    public void setReorderQty(Integer reorderQty) {
        this.reorderQty = reorderQty;
    }

    public String getUnitSize() {
        return unitSize;
    }

    public void setUnitSize(String unitSize) {
        this.unitSize = unitSize;
    }

    public Integer getMinQty() {
        return minQty;
    }

    public void setMinQty(Integer minQty) {
        this.minQty = minQty;
    }

    public Integer getMaxQty() {
        return maxQty;
    }

    public void setMaxQty(Integer maxQty) {
        this.maxQty = maxQty;
    }

    public String getProdType() {
        return prodType;
    }

    public void setProdType(String prodType) {
        this.prodType = prodType;
    }

    public String getDescription() {
        return description;
    }

    public void setDescription(String description) {
        this.description = description;
    }

    public Collection<Supplier> getSupplierCollection() {
        return supplierCollection;
    }

    public void setSupplierCollection(Collection<Supplier> supplierCollection) {
        this.supplierCollection = supplierCollection;
    }

    public Collection<Stockproduct> getStockproductCollection() {
        return stockproductCollection;
    }

    public void setStockproductCollection(Collection<Stockproduct> stockproductCollection) {
        this.stockproductCollection = stockproductCollection;
    }

    public Prodgroup getGroupId() {
        return groupId;
    }

    public void setGroupId(Prodgroup groupId) {
        this.groupId = groupId;
    }

    public Collection<Price> getPriceCollection() {
        return priceCollection;
    }

    public void setPriceCollection(Collection<Price> priceCollection) {
        this.priceCollection = priceCollection;
    }

    public Collection<Orderlineitem> getOrderlineitemCollection() {
        return orderlineitemCollection;
    }

    public void setOrderlineitemCollection(Collection<Orderlineitem> orderlineitemCollection) {
        this.orderlineitemCollection = orderlineitemCollection;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (productNumber != null ? productNumber.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Product)) {
            return false;
        }
        Product other = (Product) object;
        if ((this.productNumber == null && other.productNumber != null) || (this.productNumber != null && !this.productNumber.equals(other.productNumber))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "DB.Product[productNumber=" + productNumber + "]";
    }

}
